#!/usr/bin/env python
# -*- coding:utf8 -*-

from squirrel_core.commons.seed import CRAWL_COUNTER, PAYLOAD, SEED_KEY, CRAWL_STATUS
from squirrel_core.item.failed_seed_item import FailedSeedItem


class FailedRequestItem(FailedSeedItem):
    _is_seed = False

    def process_item(self, *args, **kwargs):
        """
            pop seed data to outside dict and return dict
        Args:
            *args:
            **kwargs:
        Returns:
            dict value
        """
        item_dict = dict(self)
        seed_data = item_dict.get("seed_data", {})
        seed_data[CRAWL_COUNTER] = int(seed_data.get(CRAWL_COUNTER, 0))
        return seed_data
